#pragma once

#include <iostream>
using namespace std;

namespace doa14
{
	template<class T>
	class arrayCalc
	{
	public:

		arrayCalc()
		{
		}

		~arrayCalc()
		{
		}

		static T min(T* a, int length)
		{
			if (length > 1){
				return std::min(*a, min(a + 1, length - 1));
			}
			else
			{
				return *a;
			}

		}

		static T max(T* a, int length)
		{
			if (length > 1){
				return std::max(*a, max(a + 1, length - 1));
			}
			else
			{
				return *a;
			}
		}

		static T sum(T* a, int length)
		{
			if (length > 1){
				return *a + sum(a + 1, length - 1);
			}
			else
			{
				return *a;
			}
		}

		static T prod(T* a, int length)
		{
			if (length > 1){
				return *a * prod(a + 1, length - 1);
			}
			else
			{
				return *a;
			}
		}

		static T avg(T* a, int length)
		{
			return sum(a, length) / length;
		}
	};

}
